import request from '@/utils/request'

export interface WorkItemPayload {
  name: string
  description?: string | null
  groupPrices: Record<string, number>
}

export function fetchWorkItems() {
  return request.get('/api/work-items')
}

export function createWorkItem(data: WorkItemPayload) {
  return request.post('/api/work-items/createAndBind', data)
}

export function updateWorkItem(id: number, data: WorkItemPayload) {
  return request.put(`/api/work-items/${id}`, data)
}

export function deleteWorkItem(id: number) {
  return request.delete(`/api/work-items/${id}`)
}
export function fetchWorkItemsByGroupId(groupId: string) {
  return request.get(`/api/work-items/group/${groupId}`)
}
